home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 15463 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: ccshst05.cs.uoguelph.ca!ccshst01!thay
  2. From: thay@uoguelph.ca (Toby K Hay)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: A real basic problem?:  (code!) long integers or compiler problem?
  5. Date: 19 Apr 1996 03:15:19 GMT
  6. Organization: University of Guelph
  7. Message-ID: <4l70g7$m7i@ccshst05.uoguelph.ca>
  8. References: <4l3mom$f26@newsbf02.news.aol.com> <4l699u$cgo@newsbf02.news.aol.com>
  9. NNTP-Posting-Host: ccshst01.uoguelph.ca
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. The Oder (theoder@aol.com) wrote:
  13. : I'm in the process of relearning C and have been doing some beginning
  14. : programs on my PC.  I have two compilers (Borland C++ and Power C).  My
  15. : problem is that when I run a program using "long" integers (i.e. declare a
  16. : variable as "long"), it locks up immediately and I have to reboot.  This
  17. : has happened with both compilers and with two different really basic
  18. : programs (i.e. just trying to do a loop that will compute the first 10
  19. : powers of 2, and another one that simply just tries to find the largest
  20. : positive long value on my computer--> I can find the largest positive int
  21. : value, but when I convert it to long, it locks up)
  22. code snipped - see original post.
  23.  
  24. It appears to me that the program finds the largest positive integer by 
  25. assigning 10000 to an int variable and then incrementing the variable 
  26. until it goes from positive to negative.  In Turbo C, with MAXINT at 
  27. about 32767, that's 20000+ iterations - this should complete in a matter 
  28. of seconds.  Using a long variable instead of an int should cause the 
  29. program to run longer because it will count instead to about 2147483647. 
  30. This will take about 30000 times as long (someone correct me if I'm 
  31. wrong).  My guess is that your computer hasn't locked up - it's just busy 
  32. counting and you can't get its attention.  If you wait longer (a day or 
  33. two) it will give you the correct answer.  
  34. Toby Hay   thay@uoguelph.ca
  35.